﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.IO;
using System.Text;

namespace Web
{
    public partial class chitiettin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string url = Convert.ToString(Request.QueryString["url"]);
            string content = GetHTML(url);
            int t = 0;
            int b = 0;
            t = content.IndexOf("<div cpms_content=\"true\"");
            if (t > 0)
                content = content.Substring(t, content.Length - t - 22);

            b = content.LastIndexOf("class=\"FollowEvent\"");
            content = content.Substring(0, b + 10);

            content = content.Replace("http://gamethu.vnexpress.net", "chitiettin.aspx?url=http://gamethu.vnexpress.net");
            content = content.Replace("\"/gl/", "chitiettin.aspx?url=http://gamethu.vnexpress.net/gl");
            content = content.Replace("/Files", "http://gamethu.vnexpress.net/Files/");
            content = content.Replace("/Library", "http://gamethu.vnexpress.net/Library");
            content = content.Replace("/Images", "http://gamethu.vnexpress.net/Images");
            content = content.Replace("/Service", "http://gamethu.vnexpress.net/Service");

            Label1.Text = content;
        }
        public string GetHTML(string url)
        {
            if (string.IsNullOrEmpty(url))
            {
                return "";
            }
            string html = "";
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream responseStream = response.GetResponseStream();
            StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
            html = reader.ReadToEnd();
            response.Close();
            reader.Close();
            return html;
        }
    }
}